package cn.school.test;

import cn.school.dao.SubjectMapper;
import cn.school.entity.Subject;
import cn.school.util.MybatisUtil;
import org.apache.ibatis.session.SqlSession;
import java.util.List;
import java.util.Scanner;

public class SubjectTest {
    public static void main(String[] args) {
        SqlSession session= MybatisUtil.get(false);
        Scanner input=new Scanner(System.in);
        while (true){
            System.out.println("课程表操作 1: 查询所有 2：根据id查subject信息 3: 更新");
            int choice=input.nextInt();
            if(choice==1){
                SubjectMapper mapper = session.getMapper(SubjectMapper.class);
                System.out.println(mapper.getClass().getName());
                List<Subject> all = mapper.findALL();
                all.forEach(System.out::println);
                session.close();
            }else if(choice==2){
                SubjectMapper mapper = session.getMapper(SubjectMapper.class);
                System.out.println(mapper.getClass().getName());
                Subject subject= mapper.get(1);
                System.out.println(subject);
                session.close();
            }else if(choice==3){
                SubjectMapper mapper = session.getMapper(SubjectMapper.class);
                System.out.println(mapper.getClass().getName());
                Subject subject=new Subject(1,"课工场",16,5);
                int zhi=mapper.update(subject);
                System.out.println(zhi);
                session.close();
            }
        }
    }
}
